import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

const state = {
  lang: 'cn'
}

const actions = {
  changeCn (cn) {
    cn.commit('translateCn')
  },
  changeEn (en) {
    en.commit('translateEn')
  }
}

const mutations = {
  translateCn (type) {
    type.lang = 'cn'
  },
  translateEn (type) {
    type.lang = 'en'
  }
}

const getters = {
  lang (type) {
    return type.lang
  }
}

export default new Vuex.Store({
  state,
  actions,
  mutations,
  getters
})
